<div class="content-section introduction">
    <div class="feature-intro">
        <h1>Slider</h1>
        <p>Slider is an input component to provide a numerical input.</p>
    </div>
    <app-inputStyleSwitch></app-inputStyleSwitch>
</div>

<div class="content-section implementation">
    <div class="card">
        <h5>Basic: {{val1}}</h5>
        <p-slider [(ngModel)]="val1"></p-slider>
    
        <h5>Input: {{val2}}</h5>
        <input type="text" pInputText [(ngModel)]="val2" readonly/>
        <p-slider [(ngModel)]="val2"></p-slider>
    
        <h5>Step: {{val3}}</h5>
        <p-slider [(ngModel)]="val3" [step]="20"></p-slider>
    
        <h5>Range: {{rangeValues[0] + ' - ' + rangeValues[1]}}</h5>
        <p-slider [(ngModel)]="rangeValues" [range]="true"></p-slider>
    
        <h5>Vertical: {{val4}}</h5>
        <p-slider [(ngModel)]="val4" orientation="vertical"></p-slider>
    </div>
</div>

<div class="content-section documentation">
    <p-tabView>
        <p-tabPanel header="Documentation">
            <h5>Import</h5>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;SliderModule&#125; from 'primeng/slider';
</app-code>

            <h5>Getting Started</h5>
            <p>Two-way binding is defined using the standard <i>ngModel</i> directive.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-slider [(ngModel)]="val"&gt;&lt;/p-slider&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class MyModel &#123;

    val: number;

&#125;
</app-code>

            <h5>Model Driven Forms</h5>
            <p>Slider can be used in a model driven form as well.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-slider formControlName="age"&gt;&lt;/p-slider&gt;
</app-code>

            <h5>Min-Max</h5>
            <p>Boundaries are specified with <i>min</i> and <i>max</i> attributes.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-slider [(ngModel)]="val" [min]="0" [max]="100"&gt;&lt;/p-slider&gt;
</app-code>

            <h5>Step</h5>
            <p>Step factor is 1 by default and can be customized with <i>step</i> option.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-slider [(ngModel)]="val" [step]="10"&gt;&lt;/p-slider&gt;
</app-code>

            <h5>Range</h5>
            <p>Range slider provides two handles to define two values. In this case, value binding should refer to an array.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-slider [(ngModel)]="rangeValues" [range]="true"&gt;&lt;/p-slider&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class MyModel &#123;

    rangeValues: number[];

&#125;
</app-code>

            <h5>Orientation</h5>
            <p>Sliders supports two <i>orientation</i>, horizontal is the default and other alternative is vertical.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-slider [(ngModel)]="val" orientation="vertical"&gt;&lt;/p-slider&gt;
</app-code>

            <h5>Properties</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>animate</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When enabled, displays an animation on click of the slider bar.</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the element should be disabled.</td>
                        </tr>
                        <tr>
                            <td>min</td>
                            <td>number</td>
                            <td>0</td>
                            <td>Mininum boundary value.</td>
                        </tr>
                        <tr>
                            <td>max</td>
                            <td>number</td>
                            <td>100</td>
                            <td>Maximum boundary value.</td>
                        </tr>
                        <tr>
                            <td>orientation</td>
                            <td>string</td>
                            <td>horizontal</td>
                            <td>Orientation of the slider, valid values are horizontal and vertical.</td>
                        </tr>
                        <tr>
                            <td>step</td>
                            <td>number</td>
                            <td>1</td>
                            <td>Step factor to increment/decrement the value.</td>
                        </tr>
                        <tr>
                            <td>range</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When specified, allows two boundary values to be picked.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                            <td>tabindex</td>
                            <td>number</td>
                            <td>0</td>
                            <td>Index of the element in tabbing order.</td>
                        </tr>
                        <tr>
                            <td>ariaLabelledBy</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Establishes relationships between the component and label(s) where its value should be one or more element IDs.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Events</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onChange</td>
                            <td>
                                event.originalEvent: Slide event <br />
                                event.value: New value <br />
                                event.values: Values in range mode <br />
                            </td>
                            <td>Callback to invoke on value change via slide.</td>
                        </tr>
                        <tr>
                            <td>onSlideEnd</td>
                            <td>
                                event.originalEvent: Mouseup event<br />
                                event.value: New value 
                            </td>
                            <td>Callback to invoke when slide stops.</td>
                        </tr>
                    </tbody>
                </table>
            </div>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-slider [(ngModel)]="val" (onChange)="handleChange($event)"&gt;&lt;/p-slider&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
handleChange(e) &#123;
    //e.value is the new value
&#125;
</app-code>

            <h5>Styling</h5>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>p-slider</td>
                            <td>Container element</td>
                        </tr>
                        <tr>
                            <td>p-slider-handle</td>
                            <td>Handle element</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Dependencies</h5>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/slider" class="btn-viewsource" target="_blank">
                <span>View on GitHub</span>
            </a>
            <a href="https://stackblitz.com/edit/primeng-slider-demo" class="btn-viewsource" style="margin-left: .5em;" target="_blank">
                <span>Edit in StackBlitz</span>
            </a>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;h5&gt;Basic: &#123;&#123;val1&#125;&#125;&lt;/h5&gt;
&lt;p-slider [(ngModel)]="val1"&gt;&lt;/p-slider&gt;

&lt;h5&gt;Input: &#123;&#123;val2&#125;&#125;&lt;/h5&gt;
&lt;input type="text" pInputText [(ngModel)]="val2" readonly/&gt;
&lt;p-slider [(ngModel)]="val2"&gt;&lt;/p-slider&gt;

&lt;h5&gt;Step: &#123;&#123;val3&#125;&#125;&lt;/h5&gt;
&lt;p-slider [(ngModel)]="val3" [step]="20"&gt;&lt;/p-slider&gt;

&lt;h5&gt;Range: &#123;&#123;rangeValues[0] + ' - ' + rangeValues[1]&#125;&#125;&lt;/h5&gt;
&lt;p-slider [(ngModel)]="rangeValues" [range]="true"&gt;&lt;/p-slider&gt;

&lt;h5&gt;Vertical: &#123;&#123;val4&#125;&#125;&lt;/h5&gt;
&lt;p-slider [(ngModel)]="val4" orientation="vertical"&gt;&lt;/p-slider&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class SliderDemo &#123;

    val1: number;

    val2: number = 50;

    val3: number;

    val4: number;

    rangeValues: number[] = [20,80];
&#125;
</app-code>
        </p-tabPanel>
        <p-tabPanel header="StackBlitz">
            <ng-template pTemplate="content">
                <iframe src="https://stackblitz.com/edit/primeng-slider-demo?embed=1" style="width: 100%; height: 768px; border: none;"></iframe>
            </ng-template>
        </p-tabPanel>
    </p-tabView>
</div>
